<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>0</div>
<script>
    let count = 0;
    let d = document.querySelector("div")
    let timer = setInterval(function () {
        count++;
        d.innerText = count;
        if (count == 100){
            //停止定时器
            clearInterval(timer)
        }
    }, 100)

    //开启只执行一次的定时器
    setTimeout(function () {
        console.log("时间到！")
    },3000)
</script>
</body>
</html>